﻿using System;
using System.Collections.Generic;
using System.Text;

namespace YouHP.Pages.Ajax
{
    public class UploadTopicImgAjax:BasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();

            string ImgSrc = YouHP.Utility.Utils.SaveRequestTopicFile(UserData.Id, 1*1024);

            StringBuilder sb = new StringBuilder();
            if (ImgSrc.Equals(""))
            {
                sb.Append("");
            }
            else
            {
                sb.Append(ImgSrc);
            }
            ResponseXML(sb);
            return;

        }
        protected void ResponseXML(StringBuilder sb)
        {
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.ContentType = "Text/html";
            System.Web.HttpContext.Current.Response.Expires = 0;

            if (sb.ToString().Equals(""))
            {
                System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">alert(\'头像图片不合法, 系统要求必须为gif jpg png图片, 大小不得超过1M\');</script>");
            }
            else
            {
                System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">parent.insertImg(\'" + sb.ToString() + "\');parent.complete();</script>");
            }
         
            System.Web.HttpContext.Current.Response.End();
        }
    }
}
